package com.guiji.text2video.fastvideo.controller;

import com.guiji.text2video.common.core.utils.poi.ExcelUtil;
import com.guiji.text2video.common.core.web.controller.BaseController;
import com.guiji.text2video.common.core.web.domain.AjaxResult;
import com.guiji.text2video.common.core.web.page.TableDataInfo;
import com.guiji.text2video.common.log.annotation.Log;
import com.guiji.text2video.common.log.enums.BusinessType;
import com.guiji.text2video.common.security.annotation.PreAuthorize;
import com.guiji.text2video.fastvideo.domain.vo.SpiderNewsStat;
import com.guiji.text2video.fastvideo.service.ISpiderNewsStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author scl
 * @date 2021-09-16
 */
@RestController
@RequestMapping("/stat")
public class SpiderNewsStatController extends BaseController {
    @Autowired
    private ISpiderNewsStatService spiderNewsStatService;

    /**
     * 查询【请填写功能名称】列表
     */
    //@PreAuthorize(hasPermi = "system:stat:list")
    @GetMapping("/list")
    public TableDataInfo list(SpiderNewsStat spiderNewsStat) {
        startPage();
        List<SpiderNewsStat> list = spiderNewsStatService.selectSpiderNewsStatList(spiderNewsStat);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
   // @PreAuthorize(hasPermi = "system:stat:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpiderNewsStat spiderNewsStat) throws IOException {
        List<SpiderNewsStat> list = spiderNewsStatService.selectSpiderNewsStatList(spiderNewsStat);
        ExcelUtil<SpiderNewsStat> util = new ExcelUtil<SpiderNewsStat>(SpiderNewsStat.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    //@PreAuthorize(hasPermi = "system:stat:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(spiderNewsStatService.selectSpiderNewsStatById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    //@PreAuthorize(hasPermi = "system:stat:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpiderNewsStat spiderNewsStat) {
        return toAjax(spiderNewsStatService.insertSpiderNewsStat(spiderNewsStat));
    }

    /**
     * 修改【请填写功能名称】
     */
    //@PreAuthorize(hasPermi = "system:stat:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpiderNewsStat spiderNewsStat) {
        return toAjax(spiderNewsStatService.updateSpiderNewsStat(spiderNewsStat));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@PreAuthorize(hasPermi = "system:stat:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(spiderNewsStatService.deleteSpiderNewsStatByIds(ids));
    }
}
